using System;
using GGFramework.Core.Timer;

namespace GGameFramework.Runtime
{
    public class TimerComponent:FrameworkComponent
    {
        TimerManager m_TimerManager;
        public override FrameworkComponentPriority Priority { get; }
        
        protected override void Awake()
        {
            base.Awake();
            
            m_TimerManager = FrameworkEntry.GetModule<TimerManager>();
        }

        public CountdownTimer CreateTimer(float duration, Action onComplete,
            bool ignoreTimeScale = false)
        {
            return m_TimerManager.CreateTimer(duration, onComplete, ignoreTimeScale);
        }

        public LoopTimer CreateLoopTimer(float interval, Action onLoop,
            int loops = -1, bool ignoreTimeScale = false)
        {
            return m_TimerManager.CreateLoopTimer(interval, onLoop, loops, ignoreTimeScale);
        }

        public FrameTimer CreateFrameTimer(int frames, Action onComplete,
            Action<int> onUpdate = null)
        {
            return m_TimerManager.CreateFrameTimer(frames, onComplete, onUpdate);
        }

        public void CancelTimer(int timerId)
        {
            m_TimerManager.CancelTimer(timerId);
        }

        public void PauseTimer(int timerId)
        {
            m_TimerManager.PauseTimer(timerId);
        }

        public void ResumeTimer(int timerId)
        {
            m_TimerManager.ResumeTimer(timerId);
        }

        public void PauseAllTimers()
        {
            m_TimerManager.PauseAll();
        }

        public void ResumeAllTimers()
        {
            m_TimerManager.ResumeAll();
        }

        public void ClearAllTimers()
        {
            m_TimerManager.ClearAll();
        }
        

    }
}